package cn.ultrarisk.scadmin.manager.biz.zookeeper.dao;

import cn.ultrarisk.mybatis.extension.domain.Page;
import cn.ultrarisk.mybatis.extension.query.Query;
import cn.ultrarisk.scadmin.manager.biz.zookeeper.entity.ZkBackup;
import cn.ultrarisk.scadmin.manager.support.BaseDAO;
import org.springframework.stereotype.Repository;

/**
 * zk备份数据操作类
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/3/28
 * @since V1.0
 */
@Repository
public class ZkBackupDAO extends BaseDAO<ZkBackup, Integer> {
    /**
     * 构造器
     */
    public ZkBackupDAO() {
        super(ZkBackup.class, ZkBackup.COLUMN_PROPERTY_MAP);
    }

    public Page<ZkBackup> findPage(Integer type, Long startTime, Long endTime, int pageNo, int pageSize) {
        Query query = Query.query(ZkBackup.TYPE, type);
        query.gte(ZkBackup.CREATE_TIME, startTime);
        query.lt(ZkBackup.CREATE_TIME, endTime);
        query.addSort(ZkBackup.CREATE_TIME, Query.Direction.DESC);
        return findPage(query, pageNo, pageSize);
    }
}
